package com.example.smartcitydemo.viewmodel.job

import androidx.lifecycle.*


import com.example.smartcitydemo.bean.DeliverPostBean
import com.example.smartcitydemo.bean.JobListBean
import com.example.smartcitydemo.ext.getLiveData
import com.example.smartcitydemo.repo.work.WorkRepo


/**
 * @PACKAGE_NAME: com.example.smartcitydemo.viewmodel.job
 * @NAME: Caleb.F
 * @DATE: 2021/11/16 20:39
 * @Email: 1919796283@qq.com
 */
class WorkShareViewModel : ViewModel() {

    private val mutableJobDeliver = MutableLiveData<JobListBean>()


    private val mutableJobPostData = MutableLiveData<DeliverPostBean>()


    val jobPostResult = mutableJobPostData.switchMap {
        getLiveData { WorkRepo.postDeliver(it) }
    }

    val jobDeliver = mutableJobDeliver.switchMap {
        liveData {
            emit(it)
        }
    }

    fun setJobListBean(jobListBean: JobListBean) {
        mutableJobDeliver.value = jobListBean
    }

    fun postDeliver(deliver: DeliverPostBean) {
        mutableJobPostData.value = deliver
    }

}